package com.example.blogsystem.controller;

import com.example.blogsystem.model.Result;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.File;
import java.io.IOException;

@RestController
@RequestMapping("/photo")
public class PhotoUploadController {

    @RequestMapping("/upload")
    public Result upload(@RequestPart MultipartFile file) throws IOException {
        file.transferTo(new File("D:/photo/" + file.getOriginalFilename()));
        return Result.success("添加成功");
    }
}
